package com.ruoyi.common.utils.file;

import com.ruoyi.common.constant.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.net.UnknownHostException;

/**
 * @author Licl
 */
@Component
public class FileHelper {

    @Autowired
    private Environment environment;
    private static Environment env;

    @PostConstruct
    public void init(){
        env = this.environment;
    }


    private static String getUrl() throws UnknownHostException {
//        return "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + env.getProperty("server.port");
        return "Http://127.0.0.1:8182";
    }

    public static String getDefaultFilePath(){
        try {
            return getUrl() + Constants.DEFAULT_PICTURE;
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return "";
    }

}
